package com.baizhi.controller;

import com.baizhi.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@CrossOrigin
@RequestMapping("/user")
@Slf4j
public class AxiosController {

    @PostMapping("/save")
    public Map<String,Object> save(@RequestBody User user){
        log.info("进入 save ....");
        log.info("user = "+user);
        Map<String, Object> map = new HashMap<>();
        map.put("status",true);
        map.put("msg","插入成功！！");

        return map;
    }

    @GetMapping("/findAll")
    public List<User> findAll(@RequestParam("username") String username,@RequestParam("password") String password){
        log.info("进入 findAll ....");
        log.info("***username = " + username);
        log.info("***password = " + password);
        List<User> users = new ArrayList<>();
        users.add(new User(1001,"小梁","123123",23,new Date()));
        users.add(new User(1002,"小黑","123123",24,new Date()));
        users.add(new User(1003,"小哈","123123",25,new Date()));
        return users;
    }

}
